[ Mega Script Archive ] [ Frequently Asked Questions ] [ Credit Card Verifier ]

Is there a fix which checks the expiry date?

  • The following piece of code was submitted by Dave MacRae, and is said to check the expiry date of your credit card, if you pass the date the user entered to the subroutine like:
      &CheckExpire($FORM{'cardexp'});

    Just put the following subroutine into the script, as well as a call similar to the one above.

      sub CheckExpire {
    
          local ($exp_date) = @_;
          $exp_date =~ s/ //g;
          ($month, $year) = split('/', $exp_date);
          (@thistime) = gmtime(time);
          $thistime[4]++;
          $date = "\"$thistime[5]/$thistime[4]/$thistime[3]:";
    
          if (length($month) > 2 or length($year) > 2) {
              return 0;
          } elsif ($month <0 or $month> 12) {
              return 0;
          } elsif ($year <$thistime[5]) { return 0; } elsif ($year="=" $thistime[5] and $month < $thistime[4]) { return 0; } else { return 1; } }

[ Mega Script Archive ]